﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace SignalBox.Core.Util
{
    public class BitmapUtils
    {

        public static Bitmap MakeTransparent(Bitmap source, Color sourceColor)
        {

            source.MakeTransparent(sourceColor);
            return source;

        }

        public static Bitmap SwapColor(Bitmap source, Color sourceColor, Color targetColor)
        {
            Bitmap target = (Bitmap)source.Clone();
            for (int x = 0; x < source.Width; x++)
            {
                for (int y = 0; y < source.Height; y++)
                {
                    Color bmpColor = source.GetPixel(x, y);
                    if (bmpColor.A == sourceColor.A && bmpColor.R == sourceColor.R && bmpColor.G == sourceColor.G && bmpColor.B == sourceColor.B)
                    {
                        target.SetPixel(x, y, targetColor);
                    }
                }
            }

            return target;
        }

    }
}
